import React,{useEffect,useState} from 'react';
import { useParams,useNavigate } from 'react-router-dom'
import axios from 'axios'
import Item from '../Movie/components/index';
const Index = () => {
    const navigator = useNavigate()
    const [details,setDetail] = useState([]);
    const fetchData = async(id)=>{
        var res = await axios.get(`http://122.112.161.135:4000/api/movieDetail?id=${id}`)
        setDetail(
            res.data.res
        )
    }
    let params = useParams();
    useEffect(()=>{
        const {id} = params
        fetchData(id)
    })
    return (
        <div>
            <Item data={details}></Item>
            <p><button onClick={()=>{
                navigator(-1)
            }}>跳转回首页</button></p>
        </div>
    );
}

export default Index;
